<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="com.zzty.springmybatis.entity.User"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ZZTY</title>
<!-- BOOTSTRAP STYLES-->
<!-- CUSTOM STYLES-->

<link rel="stylesheet"
	href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script
	src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>



<link href="/SpringMVCMybatis/css/bootstrap-datetimepicker.css"
	rel="stylesheet" />
<link href="/SpringMVCMybatis/css/bootstrap.css" rel="stylesheet" />
<link href="/SpringMVCMybatis/css/bootstrap.min.css" rel="stylesheet" />
<link href="/SpringMVCMybatis/css/custom.css" rel="stylesheet" />



<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>

<script type="text/javascript">
<%-- <%User user = (User) request.getSession().getAttribute("user"); --%>
<%-- 			String img = (String) user.getImg();%> --%>
	$(document).ready(function() {
		$("#search").click(function() {
			$("#datatable").empty();
			$.ajax({
				type : "POST",
				url : "Data/Call",
				// 				dataType : "json",
				contentType : "application/json",
				data : JSON.stringify({
					sql : $("#sql").val(),
					tablename : $("#selecttablename").val()
				}),
				success : function(data) {
						var obj = JSON.parse(data);
						for (i in obj) {
							var x = "<tr>";
							for ( var j in obj[i]) {
								x = x + "<td>" + obj[i][j] + "</td>";
							}
							x = x + "</tr>";
							$("#datatable").append(x);
					}
				},
				error : function(data) {
					alert("请输入正确语句");
				}
			});
		})
	});
</script>

<body>
	<div id="wrapper">
		<nav class="navbar navbar-default navbar-cls-top " role="navigation"
			style="margin-bottom: 0">
			<div class="navbar-header">
				<a class="navbar-brand">自在天原</a>
			</div>
			<div
				style="color: white; padding: 15px 50px 5px 50px; float: right; font-size: 16px;">
				<form action="../loginOut.jsp" method="post">
					<button type="submit" class="btn btn-danger">注销</ button>







					
				</form>
			</div>
		</nav>
		<!-- /. NAV TOP  -->
		<nav class="navbar-default navbar-side" role="navigation">
			<div class="sidebar-collapse">
				<ul class="nav" id="main-menu">
					<li class="text-center"><img src=" "
						class="user-image img-responsive" /></li>


					<li><a href="../SpringMVCMybatis/selfgread"><i
							class="fa fa-desktop fa-3x"></i> 竞赛批改</a></li>
					<li><a href="../SpringMVCMybatis/teamgread"><i
							class="fa fa-qrcode fa-3x"></i> 结对批改</a></li>
					<li><a href="../SpringMVCMybatis/que/AssginTask"><i
							class="fa fa-bar-chart-o fa-3x"></i> 竞赛布置</a></li>
					<li><a href="../SpringMVCMybatis/group/group"><i
							class="fa fa-bar-chart-o fa-3x"></i> 结对分组</a></li>
					<li><a href="../SpringMVCMybatis/SearchScore/toSearch"><i
							class="fa fa-bar-chart-o fa-3x"></i> 学生成绩</a></li>
					<li><a href="../SpringMVCMybatis/Data"><i
							class="fa fa-bar-chart-o fa-3x"></i> 数据库查询</a></li>

				</ul>

			</div>
		</nav>
		<div id="page-wrapper">
			<div id="page-inner">

				<div class="container">
					<fieldset>
						<legend>数据库查询</legend>

						<textarea id="sql" rows="10" cols="120"
							style="background: transparent"></textarea>
						<br />
						<div class="col-sm-offset-2 col-sm-10"
							style="padding: 10px 0px 0px 0px">
							操作:<select id="select" style="width: 200px">
								<option value="select">SELECT</option>
							</select> 可查询表:<select id="selecttablename" style="width: 200px">
								<option value="clazz">clazz</option>
								<option value="classgroup">classgroup</option>
								<option value="question">question</option>
								<option value="selfexam">selfexam</option>
								<option value="selfexamtransation">selfexamtransation</option>
								<option value="teamexam">teamexam</option>
								<option value="teamexamtransation">teamexamtransation</option>
								<option value="user">user</option>


							</select>
							<button class="btn btn-primary" id="search">生成结果</button>
						</div>


						<div class="row" style="padding: 50px 20px 0px 20px">

							<div class="table-responsive">
								<table class="table table-striped" id="datatable"
									style="text-align: center">

								</table>
								<input type="text" id="operation" style="display: none" />

							</div>
						</div>
						<div class="col-sm-offset-5 col-sm-7">
							<input id="ebutton" type="button" value="导出EXCEL"
								onClick="getXlsFromJsp('table1')" class="btn btn-primary"
								style="display: none">
						</div>
					</fieldset>
				</div>
			</div>
		</div>
</body>
</html>
